Masala #0919
Sonlar va bitlar
Sizga \(n\) soni beriladi. Siz shunday \(a\) sonini topingki, u \(n = a + \text{popcount}(a)\) shartni qanoatlantirsin. Bunda \(\text{popcount}(x) - x\) sonining ikkilik sanoq sistemasida ifodalanishidagi 1 lar sonidir.
Yagona qatorda bitta butun son - \(n(1 ≤ n ≤ 10^{18})\) kiritiladi.
Shartni qanoatlantiruvchi istalgan butun \(a\) sonini chiqaring. Bunday son mavjud bo‘lmasa -1 chiqaring.
# | input.txt | output.txt |
---|---|---|
1 |
4 |
-1 |
2 |
11 |
9 |
1-testda, shartni qanoatlantiruvchi \(a\) soni yo‘q ekanligini isbotlash mumkin.
2-testda, \(9_{10}\) = \(1001_2\). Ko‘rinib turibdiki, \(\text{popcount}(9)\) = \(2\). \(11 = 9 + 2\). Demak, 9 soni shartni qanoatlantiradi.